/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bis;

import java.io.Serializable;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import obj.CommonVar;

/**
 *
 * @author Administrator
 */
public class FLBookClass extends FLBase implements Serializable {

    String bm, mc;
    FLBookClass[] flbc = new FLBookClass[10];
    int index = 0, Max = 10;

    public FLBookClass() {
    }

    public FLBookClass(String bm, String mc) {
        this.bm = bm;
        this.mc = mc;
    }

    public void setDelete(String bm) {
        CommonVar.flbookclassmgr.flcdelete(bm);

    }

    public ArrayList getDateById() {
        return CommonVar.flbookclassmgr.GetDateById(bm);
    }

    public void setdataid(String id) {
        ArrayList list = CommonVar.flbookclassmgr.GetDateById(id);
        this.mc = ((FLBookClass) list.get(0)).getMc();
    }

    public ArrayList getDate() {
        return CommonVar.flbookclassmgr.GetAllDate();
    }

    public boolean isInsert() {
        if (this.isValid()) {
            boolean Insert = CommonVar.flbookclassmgr.Insert(this);
            return Insert;
        } else {
            return false;
        }

    }

    public void setUpdate(FLBookClass flbc) {
        CommonVar.flbookclassmgr.setUpdate(flbc);
    }

    public FLBookClass[] getFlbc() {
        String c = "select * from tblLx";
        String count = "select count(*) from tblLx";
        CommonVar.flbookmgr.QueryStr = count;
        ResultSet rs = CommonVar.flbookmgr.Query();
        try {
            if (rs.next()) {
                Max = rs.getInt(1);
            }
        } catch (SQLException ex) {
            Logger.getLogger(FLBookClass.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            try {
                rs.close();
            } catch (SQLException ex) {
                Logger.getLogger(FLBookClass.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        flbc = new FLBookClass[Max];
        CommonVar.flbookmgr.QueryStr = c;
        rs = CommonVar.flbookmgr.Query();
        try {
            while (rs.next()) {
                flbc[index] = new FLBookClass(rs.getString(1), rs.getString(2));
                index++;
            }
        } catch (SQLException ex) {
            Logger.getLogger(FLBookClass.class.getName()).log(Level.SEVERE, null, ex);
        }
        return flbc;
    }

    public String getBm() {
        return bm;
    }

    public void setBm(String Bm) {
        this.bm = Bm;
    }

    public String getMc() {
        return mc;
    }

    public void setMc(String mc) {
        this.mc = mc;
    }

    public boolean isValid() {
        if (mc != null && bm != null) {
            return true;
        } else {
            return false;
        }

    }

    public static void main(String[] args) {
        FLBookClass fb = new FLBookClass();
        FLBookClass[] c = fb.getFlbc();
        int l = c.length;
        for (int i = 0; i < c.length; i++) {
            System.out.println(c[i].getBm());
        }
    //fb.isFLUpdate();
    }
}
